2023-10-29
Prøv å npm linke react
1
DISPATCHER IS NULL ved app med og npm link library
First off: prøv
rm package-lock.json
rm -rf node_modules
npm i
npm link ../../app/node_modules/react
npm run build
npm link @library/package
^C
npm run dev
Second: Toggle av og på det kommenterte nedenfor. Restart server mellom hver gang
const nextConfig = {
async rewrites() {
return [
{
source: "/:path",
destination: "/",
},
];
},
};
module.exports = nextConfig;
Kan ikke brue react hooks i react component library?
Får du dispatcher is null? Eller noe a la cannot use usestate of null?
Da er det sikkert noe multiple react-versjoner greier som er trøbbelet.
Du kan fikse dette ved å legge til react og react-dom som peerDependencies i library's package.json
"peerDependencies": {
"bootstrap": ">=5.2.3",
"react": "$react",
"react-dom": "$react"
},
Eller fjern package-lock.json, node_modules og reinstaller alle packages
2024-01-06
Start
tror det er viktig å uninstalle @scope/library først?
npm link
in library
npm link @scope/library
in app
See if npm link works
Run npm run build
in the library. See if it updates the app.
If stuff doesn't update in app, try
- Restart app's dev server
- Try as suggested in response from
npm cache clean
:
npm install --cache /tmp/empty-cache
Then restart app dev server
Maybe try this on the app side
npm unlink @scope/library
npm link @scope/library
Maybe also try this on the library side
npm unlink @scope/library
npm link
I don't think it's necessary to uninstall library from node modules.
If app cant find css
attempting to import css from app (like with bootstrap css) does not always work for some reason
inject css into js so that the package imports css by itself
Reference
When npm link works, npm ls @scope/package
should return:
app@0.1.0 /home/user/code/app
└── @scope/package@0.1.0 extraneous -> ./../packages/package-components-project
Useful information about npm link and cleaning up and stuff, see README!: https://github.com/jasonsturges/vite-typescript-npm-package
2024-01-06
If you mistakenly forget to unlink, you can manually clean up artifacts from yarn or npm.
For npm, the link command creates global packages which can be removed by executing:
sudo npm rm --global "mylib"
- https://github.com/jasonsturges/vite-typescript-npm-package
- Try
Maybe unlink package?
npm unlink @scope/package
clear / swap out cache on either project
npm install --cache /tmp/empty-cache
restart all servers
- try uninstalling globally and reinstalling dependency:
sudo npm rm --global @scope/library
npm rm --global @scope/library
npm ls --global @scope/library
npm uninstall @scope/library
npm i @scope/librayr@latest --save-exact
try deleting package.json
try restarting servers???